package com.cetool.autocms.common;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * LocalDateTime反序列化
 *
 * @author 端木超群
 * @date 2021/1/12
 */
public class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
    @Override
    public LocalDateTime deserialize(JsonParser p, DeserializationContext deserializationContext) throws IOException {
        return LocalDateTime.ofEpochSecond(p.getLongValue()/1000,0, ZoneOffset.ofHours(8));
    }
}
